package com.stars.easyms.logger.config;

import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
import org.w3c.dom.Element;

/**
 * <p>className: EasyMsLoggerNamespaceHandler</p>
 * <p>description: SpringMvc框架中使用标签初始化logging模块</p>
 *
 * @author guoguifang
 * @date 2019/12/25 12:05
 * @since 1.5.0
 */
public class EasyMsLoggerNamespaceHandler extends NamespaceHandlerSupport {

    @Override
    public void init() {
        registerBeanDefinitionParser("init", new BeanParser());
    }

    private static class BeanParser extends AbstractSingleBeanDefinitionParser {

        @Override
        protected Class<?> getBeanClass(Element element) {
            return EasyMsLoggerPostProcessor.class;
        }

        @Override
        protected boolean shouldGenerateId() {
            return true;
        }
    }
}
